'''
Created on 28-May-2013

@author:Ghanshyam Agrawal
'''
import time
from caching import lru_cache


@lru_cache()
def long_running_function1():
    '''
    in long running function
    '''
    print 'long running function started'
    k = 0
    for i in range(10 ** 3):
        k = k + i
    return k


@lru_cache(3)
def long_running_function_with_params(k):
    '''
    in long running function
    '''
    print 'long running function started'
    
    for i in xrange(10 ** 7):
        k = k + i
    return k


@lru_cache()
def call_long_run_with():
    '''
    in long running function
    '''
    print 'long running function with params started'
    t = 0
    for i in xrange(10):
        time_1 = time.time()
        if(i % 5 == 2):
            t = t + long_running_function_with_params(0)
        else:
            t = t + long_running_function_with_params(i % 5)
        print 'time taken', time.time() - time_1, "seconds"
    return t



if __name__ == "__main__":
    start_time = time.time()
    print call_long_run_with()
    print time.time() - start_time, "seconds"
    print long_running_function_with_params.cache_info()
   
    




